﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode, ImageEffectAllowedInSceneView]
public class RadialAmbiguityEffect : MonoBehaviour
{
    [Range(-2f, 2f)]
    public float centerPosx;
    [Range(-2f, 2f)]
    public float centerPosy;
    [Range(0.0001f, 0.001f)]
    public float intensity = 0.0006f;

    private Material mat;

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (mat == null)
        {
            mat = new Material(Shader.Find("Custom/RadialAmbiguity"));
        }

        mat.SetFloat("_centerPosX", centerPosx);
        mat.SetFloat("_centerPosY", centerPosy);
        mat.SetFloat("_intensety", intensity);
        Graphics.Blit(source, destination, mat);
    }
}
